{php include wl_template('common/header');}
<ul class="nav nav-tabs" id="myTab">
	<li class="active">
		<a href="#">帖子详情</a>
	</li>
</ul>
<div class="app-content">
	<div class="app-form">
			<form action="" method="post" class="form-horizontal form form-validate">
				<div class="tab-content">
					<div class="panel panel-default">
						<div class="panel-heading">帖子详情</div>
						<div class="panel-body">
							<div class="form-group">
								<label class="col-sm-2 control-label">分类</label>
								<div class="col-md-3">
									<select class="form-control selecttype" name="data[onetype]" onchange="second(this)">
										<option value="">全局置顶</option>
										{loop $types $type}
											<option value="{$type['id']}">{$type['title']}</option>
										{/loop}
									</select>
								</div>
								<div id="seconds" style="display: none;">
									<label class="col-sm-2 control-label">子分类</label>
									<div class="col-md-3">
										<select class="form-control selecttype" id='twotype' name="data[type]">

										</select>
									</div>
								</div>
							</div>
							<div class="form-group" id="keyword" style="display: none">
								<label class="col-sm-2 control-label">标签</label>
								<div class="col-sm-9" id="keywordList"></div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">类型</label>
								<div class="col-sm-9">
									<label class="radio-inline">
										<input type="radio" value="1" name="type" onclick="show(1)"  /> 虚拟帖子
									</label>
									<label class="radio-inline">
										<input type="radio" value="0" name="type" onclick="show(0)" checked /> 官方公告
									</label>
								</div>
							</div>
							<div id="member" style="display: none;">
								<div class="form-group">
									<label class="col-sm-2 control-label">用户昵称</label>
									<div class="col-sm-9">
										<input type="text" name="data[nickname]"  class="form-control" placeholder="请输出虚拟发帖人昵称" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">用户电话</label>
									<div class="col-sm-9">
										<input type="tel" name="data[phone]"  class="form-control" placeholder="请输出虚拟发帖人电话" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">用户头像</label>
									<div class="col-sm-9">
										{php echo attachment_select('data[avatar]','');}
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">是否置顶</label>
									<div class="col-sm-9">
										<label class="radio-inline">
											<input type="radio" value="1" name="data[top]"  /> 置顶
										</label>
										<label class="radio-inline">
											<input type="radio" value="0" name="data[top]" checked /> 不置顶
										</label>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">分享标题</label>
								<div class="col-sm-9">
									<input type="text" name="data[share_title]"  value="{$tiezi['share_title']}" class="form-control" placeholder="请输出帖子分享标题" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">内容</label>
								<div class="col-sm-9">
									<textarea style="height: 250px;" name="data[content]" class="form-control">{$tiezi['content']}</textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">图片</label>
								<div class="col-sm-9">
									{php echo attachment_select_multi('data[img]',$tiezi['img']);}
								</div>
							</div>
							<div class="form-group" id="video-info">
								<label class="col-sm-2 control-label">视频</label>
								<div class="col-sm-9">
									<div class="input-group">
										<input type="text" value="{$tiezi['video_link']}" name="data[video_link]" class="form-control" autocomplete="off" id="cimg-videourl">
										<span class="input-group-btn">
											<button class="btn btn-default" type="button" data-toggle="selectVideo" data-input="#cimg-videourl" data-img="#pimg-videourl" >选择媒体文件</button>
										</span>
									</div>
									<div class="{if $tiezi['video_link']}show{else}hide{/if}" style="width: 300px;height: 300px;">
										<video style="max-height: 300px;" src="{$tiezi['video_link']}" controls="controls">
											您的浏览器不支持该视频播放，请更新浏览器或更换浏览器。
										</video>
									</div>
								</div>
							</div>
							{if Customized::init('pocket1500') > 0}
							<div class="form-group">
								<label class="col-sm-2 control-label">关联商户</label>
								<div class="col-sm-9">
									<select name ='storeids[]' class="form-control select2" multiple="multiple">
										{loop $storelist $pp}
										<option value="{$pp['id']}" {if in_array($pp['id'],$storelist)} selected {/if} >{$pp['storename']}</option>
										{/loop}
									</select>
									<span class="help-block">关联商户会显示在帖子详情内。</span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">查阅帖子金额</label>
								<div class="col-sm-9">
									<div class="bigdata" style="margin-top: 10px;">
										<div class="input-group data-item">
											<span class="input-group-addon">非会员</span>
											<input type="hidden" name="vipleid[]" class="form-control" value="no">
											<input type="number"  name="vipprice[]" class="form-control" value="{$viparray1['no']}">
											<span class="input-group-addon">元(最多保留两位小数)</span>
										</div>
									</div>
									<div class="bigdata" style="margin-top: 10px;">
										<div class="input-group data-item">
											<span class="input-group-addon">[{$_W['wlsetting']['halflevel']['name']}]</span>
											<input type="hidden" name="vipleid[]" class="form-control" value="0">
											<input type="number"  name="vipprice[]" class="form-control" value="{$viparray1[0]}">
											<span class="input-group-addon">元(最多保留两位小数)</span>
										</div>
									</div>
									{loop $levels $lpr}
									<div class="bigdata" style="margin-top: 10px;">
										<div class="input-group data-item">
											<span class="input-group-addon">[{$lpr['name']}]</span>
											<input type="hidden" name="vipleid[]" class="form-control" value="{$lpr['id']}">
											<input type="number"  name="vipprice[]" class="form-control" value="{$viparray1[$lpr['id']]}">
											<span class="input-group-addon">元(最多保留两位小数)</span>
										</div>
									</div>
									{/loop}
									<span class="help-block">价格不填或填0即为免费查阅，填入任意负数表示此等级用户无权查阅，价格保留两位小数。</span>
								</div>
							</div>
							{/if}
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-9">
						<input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</form>
			{if $comments}
				<div style="margin-top: 6rem;" class="panel panel-default">
					<div class="panel-body">
						<h3 style="margin-top: 0;">帖子回复:</h3>
						<div class="panel-body">
							{loop $comments $index $item}
							<div class="form-group">
								<div class="col-md-8 col-xs-12">
									<img src="{php echo tomedia($item['mid']['avatar'])}" class="scrollLoading" height="30px" width="30px" /> {$item['mid']['nickname']} {php echo date('Y-m-d H:i:s',$item['createtime'])} 说： {$item['content']}
									{loop $comments[$index]['replys'] $re}
									<div class="form-group" style="margin-top: 10px;">
										<div class="col-md-12 col-xs-12">
											<img src="{php echo tomedia($re['smid']['avatar'])}" class="scrollLoading" height="30px" width="30px" /> {$re['smid']['nickname']} {php echo date('Y-m-d H:i:s',$re['createtime'])} 回复
											<img src="{php echo tomedia($re['amid']['avatar'])}" class="scrollLoading" height="30px" width="30px" /> {$re['amid']['nickname']} 说：{$re['content']}
										</div>
									</div>
									{/loop}
								</div>
							</div>
							{/loop}
						</div>
					</div>
				</div>
			{/if}
	</div>
</div>
<script>
	function show(asd){
		if(asd){
			$('#member').show();
		}else{
			$('#member').hide();
		}
	}
	function second(asd){
        $("#keyword").hide();
        $("#keywordList").html('');
	    var onetype = $(asd).val();
	    if(!onetype){
	    	$('#seconds').hide();
	    }else{
	    	$.post("{php echo web_url('pocket/Tiezi/seconds')}",{onetype:onetype},function(d){
				if(!d.errno){
					$('#twotype').html('');
    				var html = '<option value="">请选择</option>';
					for(var i=0;i<d.twotype.length;i++){
						html += '<option value='+d.twotype[i].id+'>'+d.twotype[i].title+'</option>';
					}
					$('#twotype').append(html);
	    			$('#seconds').show();
				}else{
	    			$('#seconds').hide();
				}
			},"json");
	    }
	}
    /**
	 * 分类下面标签的显示/隐藏/更换/选择
     */
	$(".selecttype").change(function () {
	    var id = $(this).val();
	    var pos = $("#keyword");
        $("#keywordList").html('');
	    if(id > 0){
            $.post("{php echo web_url('pocket/Tiezi/getKeyword')}",{id:id},function(res){
                if(res.data) {
                    var html = '';
                    $.each(res.data, function (k, v) {
                        html += '<label class="checkbox-inline">\n' +
                            	'<input type="checkbox" name="keyword[]" value="'+v+'">'+v+'\n' +
                            	'</label>';
                    });
                    $("#keywordList").append(html);
                    pos.show();
                }else{
                    pos.hide();
				}
            },"json");
		}else{
            pos.hide();
		}
    });

	// myrequire(['select2'], function() {
	// 	$('.chosen-select').select2({
	// 		ajax: {
	// 			url: "{php echo web_url('store/merchant/getstorelist')}",
	// 			dataType: 'json',
	// 			data: function (params) {
	// 				var query = { //请求的参数, 关键字和搜索条件之类的
	// 					search: params.term //select搜索框里面的value
	// 				}
	// 				// Query paramters will be ?search=[term]&page=[page]
	// 				return query;
	// 			},
	// 			processResults: function (data) {
	// 				return {
	// 					results: data  //必须赋值给results并且必须返回一个obj
	// 				};
	// 			}
	// 		}
	// 	});
	// });
</script>
{php include wl_template('common/footer');}